package com.liu.susu.thread.task.scheduled.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Component;


/**
 * @FileName MyScheduledCondition
 * @Description
 * @Author susu
 * @date 2022-03-11
 **/
public class MyScheduledCondition implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        //从配置文件中获取属性
        String property = conditionContext.getEnvironment().getProperty("susu.task.isOpen");
        if (property != null) {
            return Boolean.valueOf(property);
        } else {
            return false;
        }
    }
}
